package flex.cc.store.enums;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

import java.util.List;
import java.util.Map;

/**
 * @author KongShiYu
 * @create 2022/1/6
 */
public enum CouponStatusEnum {

    INIT("0", "未生效"),
    ONE("1", "有效"),
    TWO("2", "已过期"),
    THREE("3", "已使用（核销完成）"),
    FOUR("4", "已取消");

    String type;
    String name;

    CouponStatusEnum(String type, String name) {
        this.type = type;
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public String getName() {
        return name;
    }

    public static String getName(String type) {
        for (CouponStatusEnum ele : CouponStatusEnum.values()) {
            if (type.equals(ele.getType())) {
                return ele.getName();
            }
        }
        return "";
    }

    public static CouponStatusEnum getEnum(String type) {
        for (CouponStatusEnum ele : CouponStatusEnum.values()) {
            if (type.equals(ele.getType())) {
                return ele;
            }
        }
        return null;
    }

    public static List<Map<String, Object>> getList() {
        List<Map<String, Object>> list = Lists.newArrayList();
        for (CouponStatusEnum ele : CouponStatusEnum.values()) {
            Map<String, Object> map = Maps.newHashMap();
            map.put("key", ele.getType());
            map.put("value", ele.getName());
            list.add(map);
        }
        return list;
    }
}

